{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ThreadPoolExecutor-5_00\n",
      "ThreadPoolExecutor-5_01\n",
      "ThreadPoolExecutor-5_02\n",
      "ThreadPoolExecutor-5_03\n",
      "ThreadPoolExecutor-5_04\n",
      "ThreadPoolExecutor-5_05\n",
      "ThreadPoolExecutor-5_06\n",
      "ThreadPoolExecutor-5_07\n",
      "ThreadPoolExecutor-5_08\n",
      "ThreadPoolExecutor-5_09\n",
      "ThreadPoolExecutor-5_010\n",
      "ThreadPoolExecutor-5_011\n",
      "ThreadPoolExecutor-5_012\n",
      "ThreadPoolExecutor-5_013\n",
      "ThreadPoolExecutor-5_014\n",
      "ThreadPoolExecutor-5_015\n",
      "ThreadPoolExecutor-5_016\n",
      "ThreadPoolExecutor-5_017\n",
      "ThreadPoolExecutor-5_018\n",
      "ThreadPoolExecutor-5_019\n",
      "ThreadPoolExecutor-5_020\n",
      "ThreadPoolExecutor-5_021\n",
      "ThreadPoolExecutor-5_022\n",
      "ThreadPoolExecutor-5_023\n",
      "ThreadPoolExecutor-5_024\n",
      "ThreadPoolExecutor-5_025\n",
      "ThreadPoolExecutor-5_026\n",
      "ThreadPoolExecutor-5_027\n",
      "ThreadPoolExecutor-5_028\n",
      "ThreadPoolExecutor-5_029\n",
      "ThreadPoolExecutor-5_030\n",
      "ThreadPoolExecutor-5_031\n",
      "ThreadPoolExecutor-5_032\n",
      "ThreadPoolExecutor-5_033\n",
      "ThreadPoolExecutor-5_034\n",
      "ThreadPoolExecutor-5_035\n",
      "ThreadPoolExecutor-5_036\n",
      "ThreadPoolExecutor-5_037\n",
      "ThreadPoolExecutor-5_038\n",
      "ThreadPoolExecutor-5_039\n",
      "ThreadPoolExecutor-5_040\n",
      "ThreadPoolExecutor-5_041\n",
      "ThreadPoolExecutor-5_042\n",
      "ThreadPoolExecutor-5_043\n",
      "ThreadPoolExecutor-5_044\n",
      "ThreadPoolExecutor-5_045\n",
      "ThreadPoolExecutor-5_046\n",
      "ThreadPoolExecutor-5_047\n",
      "ThreadPoolExecutor-5_048\n",
      "ThreadPoolExecutor-5_049\n",
      "ThreadPoolExecutor-5_050\n",
      "ThreadPoolExecutor-5_051\n",
      "ThreadPoolExecutor-5_052\n",
      "ThreadPoolExecutor-5_053\n",
      "ThreadPoolExecutor-5_054\n",
      "ThreadPoolExecutor-5_055\n",
      "ThreadPoolExecutor-5_056\n",
      "ThreadPoolExecutor-5_057\n",
      "ThreadPoolExecutor-5_058\n",
      "ThreadPoolExecutor-5_059\n",
      "ThreadPoolExecutor-5_060\n",
      "ThreadPoolExecutor-5_061\n",
      "ThreadPoolExecutor-5_062\n",
      "ThreadPoolExecutor-5_063\n",
      "ThreadPoolExecutor-5_064\n",
      "ThreadPoolExecutor-5_065\n",
      "ThreadPoolExecutor-5_066\n",
      "ThreadPoolExecutor-5_067\n",
      "ThreadPoolExecutor-5_068\n",
      "ThreadPoolExecutor-5_069\n",
      "ThreadPoolExecutor-5_070\n",
      "ThreadPoolExecutor-5_071\n",
      "ThreadPoolExecutor-5_072\n",
      "ThreadPoolExecutor-5_073\n",
      "ThreadPoolExecutor-5_074\n",
      "ThreadPoolExecutor-5_075\n",
      "ThreadPoolExecutor-5_076\n",
      "ThreadPoolExecutor-5_077\n",
      "ThreadPoolExecutor-5_078\n",
      "ThreadPoolExecutor-5_079\n",
      "ThreadPoolExecutor-5_080\n",
      "ThreadPoolExecutor-5_081\n",
      "ThreadPoolExecutor-5_082\n",
      "ThreadPoolExecutor-5_083\n",
      "ThreadPoolExecutor-5_084\n",
      "ThreadPoolExecutor-5_085\n",
      "ThreadPoolExecutor-5_086\n",
      "ThreadPoolExecutor-5_087\n",
      "ThreadPoolExecutor-5_088\n",
      "ThreadPoolExecutor-5_089\n",
      "ThreadPoolExecutor-5_090\n",
      "ThreadPoolExecutor-5_091\n",
      "ThreadPoolExecutor-5_092\n",
      "ThreadPoolExecutor-5_093\n",
      "ThreadPoolExecutor-5_094\n",
      "ThreadPoolExecutor-5_095\n",
      "ThreadPoolExecutor-5_096\n",
      "ThreadPoolExecutor-5_097\n",
      "ThreadPoolExecutor-5_098\n",
      "ThreadPoolExecutor-5_099\n",
      "4950\n",
      "MainThread0\n",
      "MainThread1\n",
      "MainThread2\n",
      "MainThread3\n",
      "MainThread4\n",
      "MainThread5\n",
      "MainThread6\n",
      "MainThread7\n",
      "MainThread8\n",
      "MainThread9\n",
      "45\n"
     ]
    }
   ],
   "source": [
    "from concurrent.futures import ThreadPoolExecutor\n",
    "\n",
    "import threading\n",
    "import time\n",
    "\n",
    "def action(max):\n",
    "    my_sum=0\n",
    "    for i in range(max):\n",
    "        print(threading.current_thread().name+''+str(i))\n",
    "        my_sum+=i\n",
    "    return my_sum\n",
    "pool=ThreadPoolExecutor(max_workers=6)\n",
    "one=pool.submit(action,100)\n",
    "print(one.result())\n",
    "print(action(10))\n",
    "def get_result(one):\n",
    "    print(one.result())\n",
    "one.add_done_callback(get_result)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n",
      "9\n",
      "10\n",
      "11\n",
      "12\n",
      "13\n",
      "14\n",
      "15\n",
      "16\n",
      "17\n",
      "18\n",
      "19\n",
      "20\n",
      "21\n",
      "22\n",
      "23\n",
      "24\n",
      "25\n",
      "26\n",
      "27\n",
      "28\n",
      "29\n",
      "30\n",
      "31\n",
      "32\n",
      "33\n",
      "34\n",
      "35\n",
      "36\n",
      "37\n",
      "38\n",
      "39\n",
      "40\n",
      "41\n",
      "42\n",
      "43\n",
      "44\n",
      "45\n",
      "46\n",
      "47\n",
      "48\n",
      "49\n",
      "49\n"
     ]
    }
   ],
   "source": [
    "def action():\n",
    "    \n",
    "    for i in range(50):\n",
    "       \n",
    "        print(i)\n",
    "    return i\n",
    "       \n",
    "        \n",
    "print(action())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n",
      "9\n"
     ]
    }
   ],
   "source": [
    "for i in range(10):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
